package com.px.auth.mapper;

import com.px.auth.model.UserModel;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

@Repository
public interface UserMapper {
//    @Select("select id,username,roles,phone,password,disabled,ip from user where username = #{username} and ifnull(disabled,0)<>1")
    @Select("select user.id,user.username,user.roles,user.phone,user.password,user.disabled,ip_black.ip " +
            "from user left join ip_black on user.ip=ip_black.ip where user.username = #{username}")
    UserModel getByUsername(String username);

    @Insert("insert into red_pack (money) values (#{money})")
    void insert(double money);

    @Update("update user set ip=#{ip} where id=#{id}")
    void updateIp(UserModel userModel);
}
